<div class="judul"><?php echo anchor($linkBack, $title);?> <span class="breadcrumb"><?php echo anchor($linkBack2,'Detail Member');?></span> <span class="breadcrumb"><?php echo "$titlePage";?></span></div>
<?php
  $flashdata = $this->session->flashdata('message');
  $messages = isset ($flashdata)?pesan($flashdata):"";
  echo "$messages";
?>
<script type="text/javascript">
  $(function() {
        $('#adik_asuh').autocomplete("<?php echo site_url('ajax_target/searchRelasiKakakPembina');?>",
        {
            parse: function(data){
                var parsed = [];
                for (var i=0; i < data.length; i++) {
                    parsed[i] = {
                        data: data[i],
                        value: data[i].adik_asuh // nama field yang dicari
                    };
                }
                return parsed;
            },
            formatItem: function(data,i,max){
                var str='<div class=result>'+data.adik_asuh+'<br />Alamat: '+data.alamat+'<br />Sekolah: '+data.sekolah+'</div>';
                return str;
            },
            width: 270, // panjang tampilan pencarian autocomplete yang akan muncul di bawah textbox pencarian
            dataType: 'json' // tipe data yang diterima oleh library ini disetup sebagai JSON
        }).result(
            function(event,data,formated){
                $(this).val(data.adik_asuh);
                $('#id_adik_asuh').val(data.id_adik_asuh);
                $('#alamat').html(data.alamat);
                $('#sekolah').html(data.sekolah);
            });
            
    $("input[type=submit]").click(function(){
        if($("#adik_asuh").val() == ""){
            alert("Nama adik asuh harus diisi");
            $("#adik_asuh").focus();
            return false;
        }
        if($("#id_adik_asuh").val() == ""){
            alert("Pilih nama adik asuh dengan benar");
            $("#adik_asuh").focus();
            return false;
        }
    })
  });          
</script>
<div class="data-input">
    <?php
      foreach ($listMember as $rows);
      echo form_open($subLink);
    ?>
    <fieldset>
        <legend><?php echo "$formTitle";?></legend>
        <label>Kakak Pembina</label><span style="font-size: 11px;padding-top: 7px;"><?php echo $rows['member']['member']?></span>
        <label>Alamat</label><span style="font-size: 11px;padding-top: 7px;"><?php echo $rows['member']['alamat']?></span>
        <label>No. Telepon</label><span style="font-size: 11px;padding-top: 7px;"><?php echo ($rows['member']['no_telp'] != '')?$rows['member']['no_telp']:'-';?></span>
        <label>Adik Asuh</label><?php echo form_input("adik_asuh","","id='adik_asuh'");?>
        <input type="hidden" name="id_adik_asuh" id="id_adik_asuh" />
        <label>Alamat</label><span style="font-size: 11px;padding-top: 7px;" id="alamat"></span>
        <label>Sekolah</label><span style="font-size: 11px;padding-top: 7px;" id="sekolah"></span>
    </fieldset>
    <?php
      echo form_hidden('id_member', $rows['member']['id']);
      echo form_submit("simpan", "Simpan", "class='button' style='margin-right:2px'");
      echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/member/relasi_kakak_pembina/".$rows['member']['id']."'".'');
      echo form_close();
    ?>
</div>
<div class="data-list">
    <table class="tabel">
        <tr>
            <th>No</th>
            <th>Nama</th>
            <th>Tgl. Lahir</th>
            <th>Jenis Kelamin</th>
            <th>Sekolah</th>
            <th>Kelas</th>
            <th>Tingkat Pendidikan</th>
            <th>Tahun Ajaran</th>
            <th>Aksi</th>
        </tr>
        <?php
        $no = 1;
        foreach ($listAdikAsuh as $row){
        ?>
          <tr class="<?php echo ($no%2)?"even":"odd";?>">
                <td style="width: 5%;text-align: center"><?php echo $no++;?></td>
                <td style="width:20%"><?php echo anchor("/adik_asuh/detail_adik_asuh/".$row['id_adik_asuh'], $row['adik_asuh']);?></td>
                <td style="width: 10%;text-align: center"><?php echo datefmysql($row['tgl_lahir']);?></td>
                <td style="width: 10%;text-align: center"><?php echo $row['jenis_kelamin']?></td>
                <td><?php echo $row['sekolah'];?></td>
                <td style="width: 5%"><?php echo $row['kelas'];?></td>
                <td style="width: 10%"><?php echo $row['tingkat_pendidikan'];?></td>
                <td style="width: 10%"><?php echo $row['tahun_ajaran']." ".$row['semester'];?></td>
                <td class="aksi" style="width: 10%">
                 <?php   
                   echo anchor('member/delete_relasi_kakak_pembina/'.$row['id'].'/'.$rows['member']['id'],'hapus','class=delete title="edit" onClick="return confirm(\'Apakah anda benar-benar akah menghapus data ini\')"');  
                 ?>
                </td>
          </tr>    
        <?php
        }
        ?>
    </table>    
</div>